import 'CardPermissonDto.dart';

/// 当前页结果集
class WriteoffBackendUserPageReponseDto {
  /// 用户ID
  final int? id;

  /// 用户名
  final String? userName;

  /// 密码
  final String? password;

  /// 角色ID
  final String? roleId;

  /// 角色名称
  final String? roleName;

  /// 邮箱
  final String? email;

  /// 启用状态，1：正常，0：停用
  final int? status;

  /// 创建时间
  final String? createTime;

  /// 是否主账号：0否 1是，默认0
  final int? mainUser;

  /// 核销客服的报价权限，1-有，0-无
  final int? quotePermission;

  /// 核销客服的核销权限
  final List<CardPermissonDto>? cardPermissionList;

  WriteoffBackendUserPageReponseDto({
    this.id,
    this.userName,
    this.password,
    this.roleId,
    this.roleName,
    this.email,
    this.status,
    this.createTime,
    this.mainUser,
    this.quotePermission,
    this.cardPermissionList,
  });

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    if (id != null) data['id'] = id;
    if (userName != null) data['userName'] = userName;
    if (password != null) data['password'] = password;
    if (roleId != null) data['roleId'] = roleId;
    if (roleName != null) data['roleName'] = roleName;
    if (email != null) data['email'] = email;
    if (status != null) data['status'] = status;
    if (createTime != null) data['createTime'] = createTime;
    if (mainUser != null) data['mainUser'] = mainUser;
    if (quotePermission != null) data['quotePermission'] = quotePermission;
    if (cardPermissionList != null)
      data['cardPermissionList'] = cardPermissionList!
          .map((e) => e.toJson())
          .toList();
    return data;
  }

  factory WriteoffBackendUserPageReponseDto.fromJson(
    Map<String, dynamic> json,
  ) {
    return WriteoffBackendUserPageReponseDto(
      id: json['id'],
      userName: json['userName'],
      password: json['password'],
      roleId: json['roleId'],
      roleName: json['roleName'],
      email: json['email'],
      status: json['status'],
      createTime: json['createTime'],
      mainUser: json['mainUser'],
      quotePermission: json['quotePermission'],
      cardPermissionList: json['cardPermissionList'] != null
          ? List<CardPermissonDto>.from(
              json['cardPermissionList'].map(
                (x) => CardPermissonDto.fromJson(x),
              ),
            )
          : [],
    );
  }
}
